<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 字面量创建对象 -->
    <!-- <script>
      // 字面量创建
      // 创建一个空对象
      var banzhang = {};

      // 给空对象添加班长的name属性
      banzhang.name = "四班长";
      banzhang.age = 19;
      banzhang["gender"] = undefined;
      console.log(banzhang);

      // 创建一个包含name、age的对象
      var broDang = {
        name: "BroDang",
        age: 40,
        gender: true,
      };
      console.log(broDang);

      // 将上述对象丢给班长做gf
      banzhang.gf = broDang;

      // 打印一下班长
      console.log("banzhang=", banzhang);
    </script> -->

    <script>
      // new Object()创建
      var obj = new Object()//{}
      console.log(obj);

      // 重复上述需求
      obj.name = "杰哥"
      obj.age = 18
      obj.gender = true
      
      obj.gf = new Object()

      obj.gf.name = "BroDang"
      obj.gf.age = 60

      console.log(obj);
      
    </script>
  </body>
</html>
